package com.dlwx.firefighting.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.TextView;

import com.dlwx.firefighting.R;
import com.dlwx.firefighting.activity.CommentActivity;
import com.dlwx.firefighting.bean.UserOrderBean;
import com.dlwx.firefighting.utils.glide.GlideImageLoader;
import com.github.jdsjlzx.ItemDecoration.DividerDecoration;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;

import java.util.List;

/**
 * 用户订单适配器
 */

public class UserOrderAdapter extends ListBaseAdapter<UserOrderBean> {

    private GlideImageLoader imageLoader;
    private Context context;
    private int loadType;

    public UserOrderAdapter(Context context,int loadType) {
        super(context);
        imageLoader = new GlideImageLoader(context);
        this.context=context;
        this.loadType=loadType;

    }

    @Override
    public int getLayoutId() {
        return R.layout.item_order_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {
         TextView tv_comment=holder.getView(R.id.tv_comment);
        tv_comment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context, CommentActivity.class));
            }
        });
//         UserOrderBean bean = mDataList.get(position);
//
//        TextView orderNumTv=holder.getView(R.id.order_num_tv);
//        TextView orderMoneyTv=holder.getView(R.id.order_money_tv);
//        TextView payTv=holder.getView(R.id.pay_tv);
//        LRecyclerView itemRcycler=holder.getView(R.id.item_recycler);
//       /* if(TextUtils.equals(bean.getPay_status(),"未付款")){
//            payTv.setText("付款");
//        }else{
//        }*/
//       if(TextUtils.equals(bean.getIs_online(),"1")){
//           payTv.setText("线下扫码支付");
//       }else{
//           payTv.setText(bean.getPay_status());
//       }
//        orderNumTv.setText("订单编号："+bean.getOrder_sn());
//        orderMoneyTv.setText(context.getString(R.string.$)+bean.getCount_amount());
//        initRecycler(itemRcycler,bean.getGoods());
    }

    private void initRecycler(LRecyclerView itemRcycler, List<UserOrderBean.GoodsBean> beans) {
        OrderGoodsAdapter mAdapter = new OrderGoodsAdapter(context);
        itemRcycler.setLayoutManager(new LinearLayoutManager(context));
        mAdapter.setDataList(beans);
        LRecyclerViewAdapter lRecyclerViewAdapter = new LRecyclerViewAdapter(mAdapter);
        lRecyclerViewAdapter.removeFooterView();
        lRecyclerViewAdapter.removeHeaderView();
        itemRcycler.setAdapter(lRecyclerViewAdapter);
        itemRcycler.setLoadMoreEnabled(false);
        itemRcycler.setPullRefreshEnabled(false);
        DividerDecoration divider = new DividerDecoration.Builder(context)
                .setHeight(R.dimen.divider_height_1_5)
                .setPadding(R.dimen.divider_padding)
                .setColorResource(R.color.white)
                .build();
        itemRcycler.addItemDecoration(divider);
        itemRcycler.refresh();

    }

}
